import $http from "../assets/js/http"
// 防止资产重复
export async function checkNumberRepeat(number, type) {
  return $http.post("Property/Property/checkNumberRepeat", {
    number,
    type
  })
}

// 房间资产初始化
export async function roomGoodsInitialize({
  area,
  dorm,
  beginLayers,
  endLayers,
  goods
}) {
  let newGoods = JSON.stringify(goods);
  return $http.post("Property/Property/roomGoodsInitialize", {
    area,
    dorm,
    beginLayers,
    endLayers,
    newGoods
  })
}

// 密码确认
export async function roomGoodsInitializeConfirmPwd(pwd) {
  return $http.post("Property/Property/roomGoodsInitializeConfirmPwd", {
    pwd
  })
}

// 领用资产查询
export async function searchUseGoods({
  _area,
  goodsNumber,
  goodsName,
  page
}) {
  return $http.post("Property/Property/searchUseGoods", {
    _area,
    goodsNumber,
    goodsName,
    page
  });
}

// 新增领用物品
export async function newUseGoods(newData) {
  return $http.post("Property/Property/newUseGoods", newData);
}

// 领用物品修改
export async function altertUseGoods(alterData) {
  return $http.post("Property/Property/altertUseGoods", alterData);
}

// 删除领用物品
export async function deleteUseGoods(serial) {
  return $http.post("Property/Property/deleteUseGoods", {
    serial
  })
}

// 查询房间物品
export async function getRoomGoods(searchData) {
  return $http.post("Property/Property/getRoomGoods", searchData)
}

// 新增房间物品
export async function newRoomGoods({
  _area,
  _dorm,
  _floor,
  _roomNumber,
  goods
}) {
  let newGoods = JSON.stringify(goods);
  return $http.post("", {
    _area,
    _dorm,
    _floor,
    _roomNumber,
    newGoods
  })
}

// 修改房间物品
export async function altertRoomGoods({
  serial,
  goodsName,
  unitPrice,
  compensationPrice,
  remark
}) {
  return $http.post("Property/Property/altertRoomGoods", {
    serial,
    goodsName,
    unitPrice,
    compensationPrice,
    remark
  })
}

// 删除房间物品
export async function deleteRoomGoods(serial) {
  return $http.post("Property/Property/deleteRoomGoods", {
    serial
  })
}

// 获取当前区域的领用物品
export async function getUseGoods(area) {
  return $http.post("Property/Property/getUseGoods", {
    area
  })
}
